﻿#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import qrcode  
import io


#img=qrcode.make("some date here")  
#img.save("Some.png")  

def get_code_by_str(text):
	if not isinstance(text,str):
		print('请输入字符串参数')
		return None
	#text="https://fir.im/z1n5"  
	qr=qrcode.QRCode(version=1,  
					 error_correction=qrcode.constants.ERROR_CORRECT_L,  
					 box_size=10,  
					 border=4,  
					 )  
	qr.add_data(text)  
	qr.make(fit=True)  

	img = qr.make_image()  
	img_data = io.BytesIO()
	img.save(img_data) 
	#print(img_data) 
	return img_data
